package com.uni.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.uni.common.util.SystemConfig;
import com.uni.support.ThreadLocalUser;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Data
@NoArgsConstructor
public class ConfessionInformDTO {
    private Long id;
    /**
     * 用户id
     */
    private Long userId;

    private String nickname;

    private String profilePhoto;

    private Integer sex;

    /*
     * 表白内容
     * */
    private String content;


    /**
     * 表白图片地址
     */
    private String picUrl;
    /**
     * 点赞数
     */
    private Integer likeNumber;
    /**
     * 评论数
     */
    private Integer commentNumber;

//    /**
//     * 是否删除
//     */
    private Integer deleted;

    private Integer hide;
    /**
     *
     */
    @JsonFormat(timezone = "GMT+8", pattern = "YYYY-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 发布时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "YYYY-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 是否置顶 0不置顶 1置顶
     */
    private Integer top;

    /**
     * 置顶结束时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "YYYY-MM-dd HH:mm:ss")
    private Date topTime;

    public String getProfilePhotoAll() {
        //ThreadLocalUser.getInstance().getUser().getId()!=userId||
        if (hide==1){
            return null;
        }
        if(profilePhoto != null && !"".equals(profilePhoto) && !profilePhoto.startsWith("http")) {
            return SystemConfig.basePath + profilePhoto;
        }
        return profilePhoto;
    }

    public List<String> getPicsAll() {
        if (picUrl==null||picUrl.trim().equals("")){
            return null;
        }
        String[] split = picUrl.split(",");

        List<String> list=new ArrayList<String>();

        for (int i=0;i<split.length;i++){
            if(split[i] != null && !"".equals(split[i]) && !split[i].startsWith("http")) {
                list.add(SystemConfig.basePath + split[i]) ;
            }
            continue;
        }
        return list;
    }
    private int checkLike;

    private int checkMe;
}
